<?php

class MysqlDBProxy {
	private static $instance;
	var $mysql_instances;
	public static function getInstance(){
		if(!self::$instance){
			self::$instance=new MysqlDBProxy();
		}
		return self::$instance;
	}
	public function  getConnection($config){
		if($this->mysql_instances[$config['host']]){
			  return $this->mysql_instances[$config['host']];
		}
   		$mysq_instance = mysqli_connect($config['host'], $config['user'], $config['password'],$config['db']);
        // Check connection
        if (mysqli_connect_errno()){
        	echo "connect database error...";
            $this->last_error = mysqli_connect_error();
            return false;
        }
        
        $this->mysql_instances[$config['host']]=$mysq_instance;
        
        return $mysq_instance;
        
	}
	
	public  function  deleConnection($host){
		if(isset($this->mysql_instances[$host])){
			unset($this->mysql_instances[$host]);
		}
	}
}

?>